package com.imay.live.adapter;

import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.imay.base.util.StringUtil;
import com.imay.live.R;
import com.imay.live.model.RoomInfoModel;
import com.imay.live.utils.GlideUtil;

import java.util.List;

/**
 * Created by jeaman on 2017/9/15.
 */

public class RoomRecommendAdapter extends BaseQuickAdapter<RoomInfoModel, BaseViewHolder> {

    public RoomRecommendAdapter(@Nullable List<RoomInfoModel> data) {
        super(R.layout.item_room_recommend, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, RoomInfoModel item) {
        String title = null;
        if (TextUtils.isEmpty(item.getTitle())) {
            if (item.getUser() != null) {
                title = item.getUser().getNick();
            }
        } else {
            title = item.getTitle();
        }
        helper.setText(R.id.room_recommend_tv_title, title);
        helper.setText(R.id.room_recommend_tv_location, TextUtils.isEmpty(item.getCity()) ? mContext.getResources().getString(R.string.str_dynamics_address) : item.getCity());
        helper.setText(R.id.room_recommend_tv_number, String.valueOf(item.getCountUser()));
        String coverUrl = StringUtil.isEmpty(item.getImgFace()) && item.getUser() != null ? item.getUser().getImgHead() : item.getImgFace();
        GlideUtil.loadRectangleImage((ImageView) helper.getView(R.id.room_recommend_iv_cover), coverUrl, R.dimen.size_4dp, R.drawable.shape_placeholder_2);
    }
}
